package com.wxsh.web;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.wxsh.entity.User;
import com.wxsh.service.UserService;

@Controller
@RequestMapping("/user")
public class UserController {

	private static final Logger logger = LoggerFactory.getLogger(UserController.class);
	
	@Autowired
	private UserService userService;
	
	@RequestMapping(value = "/getUser/{id}", method = RequestMethod.GET)
	private String list(@PathVariable Integer id, Model model) {
		logger.info("user id:"+id);
		User user = userService.findById(id);
		model.addAttribute("user", user);
		// user.jsp + model = ModelAndView
		// WEB-INF/jsp/user/"user".jsp
		return "user/user";
	}
}
